<cfinclude template="../components/settings.cfm">
<cfset returnMessage = "">

<cfset username = "">
<cfset loginReturnMessage = "">

<cfif IsDefined("doCreate")>
	
    <cfquery datasource="#fSDS#" name="postInsertService">
    
		INSERT INTO posts VALUES (NULL,'#postTitle#','#postBody#','#postAuthor#','#DateFormat(now())#','#TimeFormat(now())#')
        
	</cfquery>

	<cfset returnMessage = "Post <i>#postTitle#</i> inserted properly.">

</cfif>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Create a Post: <cfoutput>#fSSN#</cfoutput></title>
</head>

<body>

<cfif IsUserLoggedIn()>
	<center>Hi. You're on your way to creating a post!</center><br /><br />

	<cfform action="write.cfm" method="post">
	
    	Post Title: <cfinput type="text" name="postTitle" /><br />
		<cfinput type="hidden" name="postAuthor" value="#GetAuthUser()#" />
		Post Content: <cftextarea name="postBody"></cftextarea>
		<cfinput type="hidden" name="doCreate" value="1" />
		<cfinput type="submit" name="submit" value="Submit!" />
	
    </cfform>

<cfelse>

	<cfinclude template="components/loginForm.cfm">
    
</cfif>

<br /><br /><cfoutput>#returnMessage#</cfoutput>
<cfinclude template="../components/footer.cfm">
</body>
</html>
